package com.monkey.luffer.springboot.demo.basis.kcc.s3cmd;

import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.ListObjectsV2Result;
import com.amazonaws.services.s3.model.S3ObjectSummary;

import java.util.List;

public class ListObjects implements S3Oper {

	@Override
	public void request(AmazonS3 s3, MyCmd cmd) {
		ListObjectsV2Result result = s3.listObjectsV2(cmd.getBucket(), cmd.getPrefix());
		List<S3ObjectSummary> objects = result.getObjectSummaries();
		for (S3ObjectSummary os : objects) {
			System.out.println("* " + os.getKey() + "*" + os.getLastModified());
		}
	}
}
